%% initialize
clear all;
close all;
clc

cd  E:\ReplicateBuild\02_code\03_matlab


% diary('mixed_logit')
% diary off
rng(328120)

runs=400;




%%

disp('baseline')
rng(328120)

tic 
N= func_wrapper_main('mixed_logit_principal_totVA_extraX','mixed_logit_rc6_totVA_DISAD_Ndis','baseline' ,1,2015,runs      )
toc

%% 1: constant class size


disp('Constant class size')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_extraX','mixed_logit_rc6_totVA_DISAD_Ndis_Calt','constantalt' ,1,2015,runs    )
toc
%%

disp('constant class size (CFR) ')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_cfr','mixed_logit_rc6_totVA_DISAD_Ndis_cfrCalt','cfrCalt' ,1,2015, runs      )
toc


%% 2: choice set construction

disp('Choice set buffer')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_buff7','mixed_logit_rc6_totVA_DISAD_buff7','teach_buff7' ,1,2015,runs       )
toc
%
disp('First day choice sets')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_day1','mixed_logit_rc6_totVA_day1','teach_day1' ,1,2015,runs       )
toc

%
disp('Drop single application teachers')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_multiapp','mixed_logit_rc6_totVA_DISAD_multiapp','multiapp' ,1,2015 ,runs      )
toc

%
disp('Leaving out vacancies posted within week of teacher first applying')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_wkdonut','mixed_logit_rc6_totVA_DISAD_Ndis_wkdonut','teach_wkdonut' ,1,2015, runs      )
toc


disp('Drop applications ')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_extraX','mixed_logit_rc6_totVA_convert','drop_app' ,1,2015,runs       )
toc

% 3. rank order logit
%

disp('Rank-ordered logit principal preferences -- all data')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_FRPL_ro_all','mixed_logit_rc6_totVA_DISAD_Ndis','principal_ro_all' ,1,2015,runs      )
toc

disp('Rank-ordered logit principal preferences -- active choices')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_FRPL_ro_restricted','mixed_logit_rc6_totVA_DISAD_Ndis','principal_ro_restricted' ,1,2015,runs    )
toc

%
disp('Rank-ordered logit principal preferences -- Hire outcome only')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_hired','mixed_logit_rc6_totVA_DISAD_Ndis','principal_hire' ,1,2015,runs      )
toc

% 4.   Vary window in which we estimate principal preferences: baseline is all applications

disp('principal: win 14 days')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_wi14','mixed_logit_rc6_totVA_DISAD_Ndis','principal_wi14' ,1,2015,runs       )
toc

disp('principal: first half')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_first','mixed_logit_rc6_totVA_DISAD_Ndis','principal_first' ,1,2015,runs       )
toc


disp('principal: second half')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_second','mixed_logit_rc6_totVA_DISAD_Ndis','principal_second' ,1,2015,runs       )
toc

 
%% 5: Vary student type split: baseline is economic disadvantage


disp('race')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_race','mixed_logit_rc6_totVA_race','race' ,1,2015,runs     )
toc

disp('achievement')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_ach','mixed_logit_rc6_totVA_ach','ach' ,1,2015,runs       )
toc




%% 6. Alternative value-added models

disp('homog')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_homog','mixed_logit_rc6_totVA_homog','homog' ,1,2015,runs      )
toc



disp('sM')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_sM','mixed_logit_rc6_totVA_sM','sM' ,1,2015,runs      )
toc

disp('CFR')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_cfr','mixed_logit_rc6_totVA_DISAD_cfr','CFR' ,1,2015,runs      )
toc



% 7.  Allow for correlated random coefficients in teacher preferences


disp('correlated random coefficients')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_extraX','mixed_logit_rc6_totVA_DISAD_corrRC','corrRC' ,1,2015,runs      )
toc



% 8. Vary teacher preference specification to use binary logit

disp('Binary logit: no REs or FEs')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_extraX','mixed_logit_rc6_totVA_logit1','logit1' ,0,2015,runs      )
toc


disp('Binary logit: teacher REs, school FEs')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_extraX','mixed_logit_rc6_totVA_logit2','logit6' ,0,2015,runs       )
toc



disp('Binary logit: teacher FEs, school FEs')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_extraX','mixed_logit_rc6_totVA_logit3','logit7' ,0,2015,runs       )
toc


% 9. No VA in teacher preferences 

disp('no VA in teacher preferences')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_extraX','mixed_logit_rc6_totVA_DISAD_Ndis_noVA','teach_nova' ,1,2015, runs      )
toc


% 10. Multiply value-added coefficients by 10 in principal model

disp('attenuation')
tic 
N= func_wrapper_main('mixed_logit_principal_totVA_extraX_VAx10','mixed_logit_rc6_totVA_DISAD_Ndis','attenuation' ,1,2015, runs     )
toc


% 11. Efficiency 
disp('efficiency')
tic 
N= func_wrapper_efficiency('mixed_logit_principal_totVA_extraX','mixed_logit_rc6_totVA_DISAD_Ndis','efficiency' ,1,2015, runs      )
toc


%% 12. timing 


disp('month-by-month')
rng(328120)

tic
N=func_wrapper_monthbymonth('mixed_logit_principal_totVA_extraX','mixed_logit_rc6_totVA_DISAD_Ndis','monthbymonth',1, runs   );
toc 



%% 13. imputed teachers 

runs=400;
disp('with imputed teachers using teachers w/o VA')

tic
N=func_wrapper_imputed('mixed_logit_principal_totVA_imp','mixed_logit_rc6_totVA_imp','imputed',1, runs )
toc


% serial dictatorship

disp('serial dictatorship')

%tic
N=func_wrapper_serialdict('mixed_logit_principal_totVA_extraX','mixed_logit_rc6_totVA_DISAD_Ndis','serialdict',1, runs      )
%toc

